<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>将字符串转换为数值</title>
</head>
<body>
<script>
    var degreesCentigradeString = '56.02 degrees centigrade';
    var degreesCentigradeInt;
    var degreesCentigradeFloat;

    document.write('"' + degreesCentigradeString + '" is ' + parseInt(degreesCentigradeString, 10) +
            ' as an integer ' + '<br/>');

    degreesCentigradeInt = parseInt(degreesCentigradeString);
    document.write('"' + degreesCentigradeString + '" when converted to an integer equals ' +
            degreesCentigradeInt + '<br/>');

    degreesCentigradeFloat = parseFloat(degreesCentigradeString);
    document.write('"' + degreesCentigradeString + '" when converted to an floating point number equals ' +
            degreesCentigradeFloat);
</script>
</body>
</html>